package bo;


import java.util.Objects;

/**
 * @author wangly on @date 2023/6/12
 */
public class RuleFilterRuleItemIndex {
    /**
     * 索引字段1
     */
    private String pid;
    /**
     * 索引字段2
     */
    private String ruleId;
    /**
     * 索引字段3
     */
    private String feeId;
    /**
     * 索引字段4
     */
    private String deptCode;
    /**
     * 索引字段5
     */
    private String ttypeCode;

    private String sceneCode;

    public RuleFilterRuleItemIndex(String pid, String ruleId, String feeId, String deptCode, String ttypeCode, String sceneCode) {
        this.pid = pid;
        this.ruleId = ruleId;
        this.feeId = feeId;
        this.deptCode = deptCode;
        this.ttypeCode = ttypeCode;
        this.sceneCode = sceneCode;
    }

    public static RuleFilterRuleItemIndex buildByTtypeCodeAndSceneCode(String ttypeCode, String sceneCode) {
        return new RuleFilterRuleItemIndex(null, null, null, null, ttypeCode, sceneCode);
    }

    public static RuleFilterRuleItemIndex buildByRuleIdAndSceneCode(String ttypeCode, String ruleId, String sceneCode) {
        return new RuleFilterRuleItemIndex(null, ruleId, null, null, ttypeCode, sceneCode);
    }

    public static RuleFilterRuleItemIndex buildByTtypeCodeAndRuleId(String ttypeCode, String ruleId) {
        return new RuleFilterRuleItemIndex(null, ruleId, null, null, ttypeCode, null);
    }

    public String getKey() {
        return ttypeCode + "_" + ruleId + "_" + pid + "_" + deptCode + "_" + feeId + "_" + sceneCode;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        RuleFilterRuleItemIndex that = (RuleFilterRuleItemIndex) o;
        return Objects.equals(pid, that.pid) && Objects.equals(ruleId, that.ruleId) && Objects.equals(feeId, that.feeId) && Objects.equals(deptCode, that.deptCode) && Objects.equals(ttypeCode, that.ttypeCode) && Objects.equals(sceneCode, that.sceneCode);
    }

    @Override
    public int hashCode() {
        return getKey().hashCode();
    }
}
